import React from 'react';
// import { render } from 'react-dom';

//state 控制组件切换
function OK(props){
  return(
    <div>
       <button onClick={props.onClick}>loginok</button>
    </div>
   
  )

}

function NO(props){
  return(
    <button onClick={props.onClick}>LOGINNO</button>
  )
}



class App extends React.Component{
    constructor(props){
      super(props)
      this.hanLoginno=this.hanLoginno.bind(this)
      this.hanLoginok=this.hanLoginok.bind(this)
      this.state={
        isLogin:false
      }
      
      
    }

    hanLoginok(){
      this.setState({
        isLogin:true
      })
    }

    hanLoginno(){
      this.setState({
        isLogin:false
      })
    }



  render(){
    const isLogin = this.state.isLogin
    let button;
    if(isLogin)
    {
      button = <NO onClick={this.hanLoginno}/>
    }
    else{
      button = <OK onClick={this.hanLoginok}/>
    }
    return(
      <div>
        {button}
      </div>
    )
  }
}

export default App;
